package com.ruoyi.system.WebController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.ByNews;
import com.ruoyi.system.domain.ByStandardSystem;
import com.ruoyi.system.service.IByStandardSystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 体系Controller
 *
 * @author ruoyi
 * @date 2024-03-12
 */
@RestController
@RequestMapping("/byWeb/standardSystem")
public class WebByStandardSystemController  extends BaseController {

    @Autowired
    private IByStandardSystemService byStandardSystemService;

    /**
     * 查询新闻列表
     */
    @GetMapping("/list")
    public AjaxResult list(ByStandardSystem byStandardSystem)
    {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        List<ByStandardSystem> list = byStandardSystemService.selectByStandardSystemList(byStandardSystem);
        int start = (pageNum-1)*pageSize;
        int end = pageNum*pageSize;
        if(list.size()<end){
            end = list.size();
        }
        return success(list.subList(start,end),list.size());
    }

    /**
     * 获取体系详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(byStandardSystemService.selectByStandardSystemById(id));
    }


    /**
     * 获取体系详细信息
     */
    @GetMapping(value = "/getAll/{id}")
    public AjaxResult getAll(@PathVariable("id") Long id)
    {
        return success(byStandardSystemService.getAll(id));
    }
}
